package com.jiangSheng.mall.app.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.jiangSheng.mall.app.bean.ConfirmOrder;
import com.jiangSheng.mall.app.services.OrderServices;
import com.jiangSheng.mall.app.utils.CommonResult;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@Api("订单的方法")
@RequestMapping("/order")
public class OrderController {
	
	@Autowired
	private OrderServices orderServices;
	
	@ApiOperation("点击支付成功后生成订单并删除购物车信息")
	@RequestMapping(value = "/paySuccessGenerateOrder",method = RequestMethod.POST)
	public CommonResult<Integer> paySuccessGenerateOrder(ConfirmOrder confirmOrder) {
		int flag = orderServices.paySuccessGenerateOrder(confirmOrder);
		if(flag > 0) {
			return CommonResult.success(flag);
		}else {
			return CommonResult.failed();
		}
	}
}
